package com.lesson00;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestText01 {
    public static void main(String[] args) {
        //启动
        new MyFrame01();
    }
}

class MyFrame01 extends Frame {
    public MyFrame01() {
        TextField textField = new TextField();
        add(textField);
        //监听输入
        MyActionListener2 myActionListener2 = new MyActionListener2();

        textField.addActionListener(myActionListener2);
        //替换编码
        textField.setEchoChar('*');

        setVisible(true);
        pack();
    }
}
class MyActionListener2 implements ActionListener{
    @Override
    public void actionPerformed(ActionEvent e) {
        //获取输入
        TextField field = (TextField)e.getSource();//获得资源
        System.out.println(field.getText());
        field.setText("");//设置为空
    }
}